Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
RichardBronosky / pep8_cheatsheet.py
Created December 27, 2015 06:25
PEP-8 cheatsheet
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""This module's docstring summary line.
This is a multi-line docstring. Paragraphs are separated with blank lines.
Lines conform to 79-column limit.
Module and packages names should be short, lower_case_with_underscores.
Notice that this in not PEP8-cheatsheet.py
@trongthaonh
trongthaonh / rails-validates.md
Created November 7, 2016 03:44 — forked from nashirox/rails-validates.rb
Rails のバリデーション用正規表現集

数字

# 全て数値(全角)
/^[0-9]+$/

# 全て数値(半角)
/^[0-9]+$/

# 全て数値(全角,半角)
@s8sg
s8sg / NetworkingFirecracker.md
Last active May 4, 2024 18:51
Networking with Firecracker

Create Bridge interface on the host and give internet access

sudo ip link add name br0 type bridge
sudo ip addr add 172.20.0.1/24 dev br0
sudo ip link set dev br0 up
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables --table nat --append POSTROUTING --out-interface enp3s0 -j MASQUERADE
sudo iptables --insert FORWARD --in-interface br0 -j ACCEPT

Create a tap device and link to the bridge

@JadenGeller
JadenGeller / DragModifier.swift
Last active May 4, 2024 18:50
NSFilePromiseProvider with SwiftUI, to drag a file that's loaded asynchronously
import SwiftUI
import UniformTypeIdentifiers
struct FileDragProvider: NSViewRepresentable {
var filePromise: FilePromise
var preview: PlatformImage
class NSViewType: NSView, NSFilePromiseProviderDelegate, NSDraggingSource {
var filePromise: FilePromise
var preview: PlatformImage
@PROPHESSOR
PROPHESSOR / LANGUAGE.EO
Created May 5, 2021 08:50
Esperanto Zandronum doom localization
[enu default]
TXT_D1E1 = "Gxisgenue en la Mortintoj";
TXT_D1E2 = "La Bordoj de Infero";
TXT_D1E3 = "";
TXT_D1E4 = "Via Karno Konsumita"; // The episode and levels' names in E4 are taken from the Bible. Proverbs 5:11
TXT_D2E1 = "Infero Sur La Tero";
TXT_D2E2 = "Nenia Ripozo por la Vivantoj"; // References "No rest for the wicked" in Isaiah 48:22
TXT_PLUT_EP = "La Eksperimento de Plutonia";
TXT_TNT_EP = "TNT: Mavalucio";
@J-Pster
J-Pster / instalar_cypress_wsl2.md
Last active May 4, 2024 18:49
Como instalar o Cypress no WSL2 (+ Puppeteer)

Instalando o Cypress no WSL 2 (+ Usando o Puppeteer em testes)

Depois de muito tempo sofrendo, finalmente descobri como instalar o Cypress de forma limpa e tranquila no WSL2, e vou te ensinar, e além disso, quando você instalar aqui o Cypress, testes que usam o Puppeteer que é a mesma dependência que o Cypress usa, também passarão a rodar no seu WSL2!

Esse tutorial é muito útil se você está tendo o erro error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory ou algo parecido!

Créditos ao autor original, nesse link!

Antes de executar qualquer comando, ou código que eu tenha deixado aqui, tenta primeiro entender o que está escrito, e para os .sh, dê uma lida neles, mesmo que eu diga que seja seguro, é sempre bom olhar!

minh.nguyen: Thông thường thì em sẽ follow theo (hầu hết) các bước sau:

  • RTFM.
  • Dựng và chạy hệ thống với các settings được recommend trong doc. Ví dụ Redis sẽ có sentinel hoặc Redis cluster hoặc standalone.
  • Explore tất cả các feature của system hoặc tất cả interface của library, nhất là những feature nào có vẻ fancy.
  • Build from source. Chạy lại bằng build object được sinh ra. Ngó thử xem hệ thống có bao nhiêu components, dependencies.
  • Đọc thử design doc nếu có
  • Debug thử xem giữa các component liên hệ với nhau như thế nào. Thông thường các hệ thống đều có doc.
  • Pick một flow đơn giản nhất, Tìm thử entrypoint trong code. Đặt debugger xem thử chạy ra sao.
  • Change thử một feature nho nhỏ xem thê nào
@jboner
jboner / latency.txt
Last active May 4, 2024 18:45
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@UbuntuEvangelist
UbuntuEvangelist / How to Install Doxygen on Ubuntu
Created September 5, 2023 21:40
How to Install Doxygen on Ubuntu 22.04.3 LTS (jammy)
Doxygen is the de facto standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, and to some extent D. Doxygen also supports the hardware description language VHDL.
sudo apt-get install flex
sudo apt-get install bison
git clone https://github.com/doxygen/doxygen.git
cd doxygen
@superkojiman
superkojiman / namemash.py
Last active May 4, 2024 18:42
Creating a user name list for brute force attacks.
#!/usr/bin/env python3
'''
NameMash by superkojiman
Generate a list of possible usernames from a person's first and last name.
https://blog.techorganic.com/2011/07/17/creating-a-user-name-list-for-brute-force-attacks/
'''